import rospy
import actionlib

from chatgpt_ros_msg.srv import chat, chatRequest, chatResponse


class ChatClient():

    def __init__(self,input_message):
      client = rospy.ServiceProxy("chat", chat)
      client.wait_for_service()
      req = chatRequest()
      rospy.loginfo(input_message)

      req.prompt = f"现在存在两个函数：forward_thread.run()和circle_thread.run()，前者的功能是转圈，后者的功能是直行，你先需要根据下列的提示输出一个答案，你的答案只有两种forward_thread.run()或者circle_thread.run()，不能携带其它文字以及单词，现在提示是[{input_message}]"
      rospy.loginfo(req.prompt)
      self.resp = client.call(req)
      rospy.loginfo("响应结果:%s", self.resp.result)
    
    def getcode(self):
       return self.resp.result

# def main():
#     rospy.init_node("chat_ros_client")

#     action_client = ChatClient("你好")
    
#     rospy.spin()

# if __name__ == '__main__':
#     main()
